import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/department_entity.dart';
import 'package:enterprise_v6_app/app/data/common/choice_bean.dart';


DepartmentEntity $DepartmentEntityFromJson(Map<String, dynamic> json) {
  final DepartmentEntity departmentEntity = DepartmentEntity();
  final int? bindStatus = jsonConvert.convert<int>(json['bindStatus']);
  if (bindStatus != null) {
    departmentEntity.bindStatus = bindStatus;
  }
  final List<DepartmentEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DepartmentEntity>(e) as DepartmentEntity).toList();
  if (children != null) {
    departmentEntity.children = children;
  }
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    departmentEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    departmentEntity.createBy = createBy;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    departmentEntity.createDate = createDate;
  }
  final int? departmentLevel = jsonConvert.convert<int>(json['departmentLevel']);
  if (departmentLevel != null) {
    departmentEntity.departmentLevel = departmentLevel;
  }
  final String? departmentName = jsonConvert.convert<String>(json['departmentName']);
  if (departmentName != null) {
    departmentEntity.departmentName = departmentName;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    departmentEntity.id = id;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    departmentEntity.parentId = parentId;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    departmentEntity.path = path;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    departmentEntity.updateBy = updateBy;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    departmentEntity.updateDate = updateDate;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    departmentEntity.level = level;
  }
  final int? workDepartmentType = jsonConvert.convert<int>(json['workDepartmentType']);
  if (workDepartmentType != null) {
    departmentEntity.workDepartmentType = workDepartmentType;
  }
  return departmentEntity;
}

Map<String, dynamic> $DepartmentEntityToJson(DepartmentEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['bindStatus'] = entity.bindStatus;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createDate'] = entity.createDate;
  data['departmentLevel'] = entity.departmentLevel;
  data['departmentName'] = entity.departmentName;
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['path'] = entity.path;
  data['updateBy'] = entity.updateBy;
  data['updateDate'] = entity.updateDate;
  data['level'] = entity.level;
  data['workDepartmentType'] = entity.workDepartmentType;
  return data;
}

extension DepartmentEntityExtension on DepartmentEntity {
  DepartmentEntity copyWith({
    int? bindStatus,
    List<DepartmentEntity>? children,
    String? companyCode,
    String? createBy,
    String? createDate,
    int? departmentLevel,
    String? departmentName,
    String? id,
    String? parentId,
    String? path,
    String? updateBy,
    String? updateDate,
    int? level,
    int? workDepartmentType,
  }) {
    return DepartmentEntity()
      ..bindStatus = bindStatus ?? this.bindStatus
      ..children = children ?? this.children
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createDate = createDate ?? this.createDate
      ..departmentLevel = departmentLevel ?? this.departmentLevel
      ..departmentName = departmentName ?? this.departmentName
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..path = path ?? this.path
      ..updateBy = updateBy ?? this.updateBy
      ..updateDate = updateDate ?? this.updateDate
      ..level = level ?? this.level
      ..workDepartmentType = workDepartmentType ?? this.workDepartmentType;
  }
}
